package com.xiaohuihui.springbootsecurity.controller;

import com.xiaohuihui.springbootsecurity.domain.ApiResult;
import com.xiaohuihui.springbootsecurity.domain.User;
import com.xiaohuihui.springbootsecurity.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping("/user/login")
    public ApiResult<Object> login(@RequestBody User user){
        //登录
        return loginService.login(user);
    }

    @PostMapping("/user/logout")
    public ApiResult<Object> logout(){
        loginService.logout();
        return ApiResult.ok();
    }
}
